﻿using UnityEngine;
using UnityEditor;
using System.Collections;
using UnityEditor.Callbacks;
using System.Collections.Generic;
using System.IO;

public class ReporterEditor : UnityEditor.AssetModificationProcessor
{
    [InitializeOnLoad]
    public class BuildInfo
    {
        static BuildInfo()
        {
            EditorApplication.update += Update;

        }

        static bool isCompline = true;
        static void Update()
        {
            if (!EditorApplication.isCompiling && isCompline)
            {
                Debug.Log("Finish Complie");
                if (!Directory.Exists(Application.dataPath + "/StreamingAssets"))
                {
                    Directory.CreateDirectory(Application.dataPath + "/StreamingAssets");
                }
                string info_path = Application.dataPath + "/StreamingAssets/buildinfo.txt";
                StreamWriter buildinfo = new StreamWriter(info_path);
                buildinfo.Write("Build from " + SystemInfo.deviceName + " On " + System.DateTime.Now.ToString());
                buildinfo.Close();
            }
            isCompline = EditorApplication.isCompiling;
        }
    }
   
}
